notes

setup

load data

position summary

id nrec npos bat firstrec lastrec
32 236279 1282 1282 100 2023-10-09 15:43:00 2024-06-02 22:03:14
52 242538 872 871 100 2024-05-13 21:20:53 2024-06-02 16:53:27
54 242540 880 879 100 2024-05-15 13:09:05 2024-06-02 16:41:39
56 242543 524 518 100 2024-05-14 13:02:09 2024-06-02 16:05:05
47 242533 960 959 100 2024-05-14 16:28:45 2024-06-02 16:01:07
48 242534 540 538 100 2024-05-13 16:27:53 2024-06-02 15:27:51
49 242535 1000 1000 100 2024-05-13 15:36:06 2024-06-02 15:08:22
55 242542 392 392 100 2024-05-15 11:55:53 2024-06-02 14:58:40
35 236282 544 541 100 2023-10-09 15:42:45 2024-06-02 14:26:57
53 242539 450 450 100 2024-05-15 15:15:50 2024-06-02 14:17:44
51 242537 296 296 0 2024-05-07 16:51:36 2024-06-02 13:38:05
42 242528 864 856 91 2024-05-15 14:02:14 2024-06-02 13:34:12
23 233359 9577 9498 100 2023-05-16 14:55:05 2024-06-01 21:33:08
29 236276 1270 1270 97 2023-10-09 15:43:00 2024-06-01 19:10:34
31 236278 2116 2116 100 2023-10-09 15:44:14 2024-06-01 17:48:29
40 242526 165 165 83 2024-04-19 15:51:26 2024-06-01 17:25:13
33 236280 854 849 95 2023-10-09 15:43:16 2024-06-01 17:20:04
27 236274 722 721 81 2023-10-09 15:43:06 2024-06-01 17:17:53
5 233341 7368 7352 88 2023-05-16 14:38:01 2024-06-01 17:06:39
38 242524 576 576 100 2024-05-20 17:26:44 2024-06-01 16:58:44
43 242529 656 656 50 2024-05-07 13:37:30 2024-06-01 16:39:12
50 242536 385 384 83 2024-05-14 20:38:59 2024-06-01 16:19:03
30 236277 1523 1523 87 2023-10-13 14:53:06 2024-06-01 15:49:40
34 236281 1308 1307 100 2023-10-09 15:44:16 2024-06-01 15:42:39
26 236273 2886 2886 100 2023-10-09 15:43:06 2024-06-01 15:41:55
28 236275 1017 1017 82 2023-10-09 15:42:46 2024-06-01 15:31:14
44 242530 340 340 76 2024-05-13 19:58:06 2024-06-01 15:30:42
45 242531 300 300 87 2024-05-13 18:35:00 2024-06-01 14:07:20
37 242523 976 976 100 2024-05-13 22:15:40 2024-06-01 13:47:56
57 242544 282 282 83 2024-05-14 14:04:24 2024-06-01 13:36:22
36 242522 498 498 100 2024-05-20 13:58:14 2024-06-01 13:30:43
16 233352 1587 1575 75 2023-05-16 14:53:53 2024-06-01 11:51:53
11 233347 2336 2324 95 2023-05-16 14:50:53 2024-06-01 11:44:14
4 233340 2719 2571 100 2023-05-16 14:38:36 2024-06-01 10:26:36
39 242525 165 165 0 2024-05-13 12:24:36 2024-06-01 09:28:23
19 233355 1993 1981 93 2023-05-16 14:52:35 2024-06-01 05:57:34
15 233351 2325 2313 93 2023-05-16 14:50:53 2024-06-01 05:39:37
20 233356 9658 9621 100 2023-05-16 14:51:45 2024-06-01 00:49:06
22 233358 171 152 100 2023-05-16 14:55:36 2024-06-01 00:17:17
41 242527 528 527 100 2024-05-20 18:18:24 2024-05-31 17:46:38
21 233357 35 22 100 2023-05-16 14:50:44 2024-05-26 03:26:36
9 233345 987 976 0 2023-05-16 14:38:54 2024-05-25 19:40:15
8 233344 2615 2604 0 2023-05-16 14:38:07 2024-05-21 19:33:59
46 242532 578 578 6 2024-05-07 15:43:05 2024-05-14 15:48:05
2 233338 2548 2537 31 2023-05-16 14:37:44 2024-04-09 03:13:15
10 233346 1468 1457 0 2023-05-16 14:37:30 2024-02-27 18:46:05
18 233354 16579 16557 69 2023-05-16 14:54:14 2024-01-25 16:27:12
12 233348 4372 4350 75 2023-05-16 14:39:06 2024-01-14 11:50:05
24 233360 8123 8086 42 2023-05-16 14:54:23 2024-01-11 23:03:44
7 233343 15442 15413 23 2023-05-16 14:38:35 2023-11-20 22:22:09
6 233342 1090 1079 84 2023-05-16 14:37:44 2023-08-12 04:29:19
1 233337 2286 2195 6 2023-05-16 14:39:05 2023-07-17 12:19:45
17 233353 1133 1069 0 2023-05-16 14:52:45 2023-06-30 19:29:35
3 233339 57 46 100 2023-05-16 14:39:08 2023-06-24 18:40:14
25 233361 56 45 100 2023-05-16 14:53:53 2023-06-24 18:39:40
13 233349 901 889 0 2023-05-16 14:52:29 2023-06-22 15:25:40
14 233350 16 5 100 2023-05-16 14:52:06 2023-05-16 18:37:05

most recent positions (last 5 days)

all positions

colors <- rainbow(length(tags))

# get current date to remove tags that haven't recently transmitted
curdate <- as.numeric(as.POSIXct(Sys.Date()))
cutoffdate <- curdate - 5*24*60*60

# legend
leg_ids <- vector()
leg_col <- vector()

# set up leaflet object
m <- leaflet()

# initial zoom for map
initlon <- -70.3
initlat <- 41.7
initzoom <- 6

# add in positions
for(i in 1:length(tags)) {
  # get positions
  pcur <- tags[[i]]
  pcur <- pcur[pcur$Latitude != 0, ]
  # pcur <- tail(pcur, 5)
  # pcur$datenum <- as.numeric(as.POSIXct(pcur$UTC_datetime, tz = "UTC", format = "%Y-%m-%d %H:%M:%S"))
  
  # check to see if there are recent positions
  # otherwise don't add any points
  # if(pcur$datenum[nrow(pcur)] > cutoffdate) {
    # add to legend
    leg_ids <- c(leg_ids, pcur$device_id[1])
    leg_col <- c(leg_col, colors[i])
    
    # formatted lat and lon
    lon_tmp <- pcur$Longitude
    lat_tmp <- pcur$Latitude
    
    lon_sign <- sign(lon_tmp)
    lat_sign <- sign(lat_tmp)
    
    lon_abs <- abs(lon_tmp)
    lat_abs <- abs(lat_tmp)
    
    lon_tmp_min <- round((lon_abs - floor(lon_abs))*60, 3)
    lat_tmp_min <- round((lat_abs - floor(lat_abs))*60, 3)
    
    lon_formatted <- paste0(floor(lon_abs)*lon_sign, "° ", lon_tmp_min, "\'")
    lat_formatted <- paste0(floor(lat_abs)*lat_sign, "° ", lat_tmp_min, "\'")
    
    
    m <- addTiles(m, urlTemplate="http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}")
    
    m <- addCircleMarkers(m, lng = pcur$Longitude, lat = pcur$Latitude, popup = paste0(pcur$device_id[1], " ", pcur$UTC_datetime, " (", lon_formatted, ",", lat_formatted, ") ", pcur$Quality), radius = 7, fillOpacity = 0.5, stroke = FALSE, color = colors[i])
  # }
}

# sort labels
oo <- order(leg_ids)
leg_ids <- leg_ids[oo]
leg_col <- leg_col[oo]

# add legend
# m <- addLegend(m, "bottomright", colors = leg_col, labels = leg_ids)

m <- setView(m, lng = initlon, lat = initlat, zoom = initzoom)

m
par(mfrow = c(1, 5))
l1 <- 1:12
l2 <- 13:24
l3 <- 25:37
l4 <- 38:49
l5 <- 50:59
plot(0, 0, xlab = "", ylab = "", axes = FALSE)
legend("center", legend = leg_ids[l1], pch = 16, col = leg_col[l1])
plot(0, 0, xlab = "", ylab = "", axes = FALSE)
legend("center", legend = leg_ids[l2], pch = 16, col = leg_col[l2])
plot(0, 0, xlab = "", ylab = "", axes = FALSE)
legend("center", legend = leg_ids[l3], pch = 16, col = leg_col[l3])
plot(0, 0, xlab = "", ylab = "", axes = FALSE)
legend("center", legend = leg_ids[l4], pch = 16, col = leg_col[l4])
plot(0, 0, xlab = "", ylab = "", axes = FALSE)
legend("center", legend = leg_ids[l5], pch = 16, col = leg_col[l5])

status plots